local skynet = require "skynet"
local cluster = require "skynet.cluster"
require "skynet.manager"

local filelog = require "filelog"
local configdao = require "configdao"

skynet.start(function()
	skynet.error("gang28node start")
	math.randomseed(os.time())
	skynet.newservice("nodelog")
	local confsharesvr = skynet.newservice("confshare")
	skynet.call(confsharesvr, "lua", "start")
	cluster.send("gatenode", ".router", "gamenode_init", skynet.getenv("nodename"))

	local node = configdao.get_cfgsvrs_key(skynet.getenv("nodename"))
	if node.debug_console_port then
		skynet.newservice("debug_console", node.debug_console_port)
	end

	local timersvr = skynet.newservice("timercenter")
	skynet.call(timersvr, "lua", "init")  -- 默认就是1000， 也就是1s

	skynet.name(".nodeuuid", skynet.uniqueservice("nodeuuid"))

	---方便拉取配置
    skynet.name(".gmmqredis", skynet.newservice("redisdb"))	
	skynet.call(".gmmqredis", "lua", "init", configdao.get_cfgsvrs_key("gmmqredis"))

	skynet.name(".tablerecordlog", skynet.newservice("tabledatalog"))
	skynet.call(".tablerecordlog", "lua", "init", "tablerecord")
	skynet.name(".tablereplaylog", skynet.newservice("tabledatalog"))
	skynet.call(".tablereplaylog", "lua", "init", "tablereplay")

	-- skynet.name(".jackpotlog", skynet.newservice("datalog"))
	-- skynet.call(".jackpotlog", "lua", "init", "jackpot") 
	-- skynet.name(".jackpotmgr", skynet.newservice("jackpotmgr"))
	-- skynet.call(".jackpotmgr", "lua", "init", "gang28node_conf", JACKPOTGAMEID.GANG28) 

	skynet.name(".router", skynet.uniqueservice("router"))
	cluster.open(skynet.getenv("nodename"))

	skynet.exit()
end)
